﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WpfDemo.Models.Sys;

namespace WpfDemo.Models.Context
{
    public class EfContext : DbContext
    {
        public EfContext() { }
        public EfContext(DbContextOptions<EfContext> options) : base(options)
        {//继承DbContext建库方法


        }


        //protected readonly IConfiguration Configuration;

        //public EfContext(IConfiguration configuration)
        //{
        //    Configuration = configuration;
        //}

        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            //CodeFirst使用
            string rootPath = AppDomain.CurrentDomain.BaseDirectory + "db\\weight.db";
            options.UseSqlite($"Data Source={rootPath}");
        }



        public virtual DbSet<UserEntity> users { get; set; }

        public virtual DbSet<RoleEntity> roles { get; set; }

        public virtual DbSet<ModuleEntity> modules { get; set; }


        public virtual DbSet<ButtonEntity> bottons { get; set; }

        public virtual DbSet<AuthEntity> auths{ get; set; }

    }



}
